{extend name="common/adminBase" /}
{block name="body"}
<body>
<style>
    .r{
        float: right;
    }
</style>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block r">
                            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                        </div>

                        <a class="layui-btn " onclick="xadmin.open('添加课题','addmember?cid={$id}',800,600)"><i class="layui-icon"></i>添加</a>
                    </form>

                </div>

                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>审核部门名称</th>
                            <th>审核范围</th>
                            <th>添加时间</th>
                        
                            <th>当前状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="info" id="v"}
                        <tr>
                            <td>{$v.id}</td>
                            <td>{$v.title}</td>
                            <td>{$v.type}</td>
                            <td>{$v.time|date='Y-m-d H:i:s'}</td>

                            <td>
                                {if $v.status == 1}
                                <input type="checkbox" name="switch" value="{$v.id}" lay-skin="switch" lay-filter="switchTest"  checked >
                                {else/}
                                <input type="checkbox" name="switch" value="{$v.id}" lay-skin="switch" lay-filter="switchTest" >
                                {/if}
                            </td>
                            <td class="td-manage">
                                <a class="layui-btn layui-btn layui-btn-xs"  onclick="xadmin.open('编辑','/index/classcontroller/memneredit/?id={$v.id}',800,600)" >
                                    <i class="layui-icon">&#xe642;</i>编辑
                                </a>
                                <button class="layui-btn-danger layui-btn layui-btn-xs"  onclick="member_del({$v.id})" href="javascript:;" >
                                    <i class="layui-icon">&#xe640;</i>删除
                                </button>
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        <div>
                       
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use('form', function(){
        var  form = layui.form;
        //监听指定开关
          form.on('switch(switchTest)', function(data){
                $.ajax({
                url:"memberstatus",
                data:{id:data.value,status:data.elem.checked},
                type:'post',
                dataType: 'json',
                success:function (res) {
                    if (res.status ==1){
                        layer.msg(res.msg,{icon:1,time:1500},function () {
                            location.reload();
                        });
                    }else{
                        layer.alert(res.msg,function (index) {
                            layer.close(index);
                        })
                    }
                }
            })
          });
    });

    /*用户-停用*/
    function member_del(id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                url:'delmember',
                data:{id:id},
                type:'post',
                dataType:'json',
                success:function (res) {
                    if (res.status ==1){
                        layer.msg(res.msg,{icon:1,time:1500},function () {
                            location.reload();
                        });
                    }else{
                        layer.alert(res.msg,function (index) {
                            layer.close(index);
                        })
                    }
                }
            })

        });
    }


</script>

{/block}